package com.anjie.powerproject.repository;

import com.anjie.powerproject.entity.PredictElectricity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

public interface PredictElectricityRepository extends JpaRepository<PredictElectricity,Integer> {
    @Query(nativeQuery = true,value = "select * from predict_dl pd order by pd.sdate desc limit 1")
    PredictElectricity getPredictElectricityByDate();

    /*@Query(nativeQuery = true,value = "select * from predict_dl pd where pd.id = ?1 order by pd.sdate desc limit 1")
    PredictElectricity getPredictElectricityByDateAnId(Integer id);*/

    /*@Query(nativeQuery = true,value = "select * from predict_dl pd where DATE_FORMAT(pd.sdate,'%Y-%m-%d')=?1 and pd.id = ?2")
    PredictElectricity findPredictDlByDateAndId(String day,Integer id);*/

    @Query(nativeQuery = true,value = "select * from predict_dl pd where DATE_FORMAT(pd.sdate,'%Y-%m-%d')=?1 and pd.graph_id = ?2 and stgy_type = ?3")
    PredictElectricity findPredictDlByDateAndId(String day,Integer graphId,Integer stgyType);

    // todo 这里要修改
    @Query(nativeQuery = true, value = "select * from predict_dl limit 1")
    PredictElectricity getSelectedPredictElectricity();
}
